package com.javatest.redpacket.service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @date 2020-08-06 上午10:57
 */
public interface RedisRedPacketService {

    /**
     * 保存redis抢红包列表
     * Save user red packet by redis.
     *
     * @param redPacketId the red packet id
     * @param unitAmount  the unit amount
     */
    void saveUserRedPacketByRedis(Long redPacketId, Double unitAmount);

    /**
     * 通过redis实现抢红包
     * Grab red packet by redis long.
     *
     * @param redPacketId the red packet id 红包编号
     * @param userId      the user id 用户编号
     * @return the long
     * 0-没有库存, 失败
     * 1-成功, 且不是最后一个
     * 2-成功, 且是最后一个
     */
    Long grabRedPacketByRedis(Long redPacketId, Long userId);
}
